//
//  CourseLeaderCell.m
//  ShowYork
//
//  Created by hxh on 2020/10/22.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "LessonLeaderCell.h"

@interface LessonLeaderCell ()
@property (nonatomic,strong)UIImageView *headerImgView;
@property (nonatomic,strong)UILabel *nameLb;
@property (nonatomic,strong)UILabel *descLb;
@property (nonatomic,strong)UIImageView *icon;
@end

@implementation LessonLeaderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUI];
    }
    return self;
}
- (void)setUI{
    self.headerImgView = [[UIImageView alloc]init];
    [self.contentView addSubview:self.headerImgView];
    [self.headerImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(kScreenW/4*3);
    }];
    self.nameLb = [[UILabel alloc]init];
    self.nameLb.font = [UIFont boldSystemFontOfSize:18];
    self.nameLb.textColor = RGBA(39, 25, 21, 1);
    [self.contentView addSubview:self.nameLb];
    [self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(16);
        make.top.equalTo(self.headerImgView.mas_bottom).offset(24);
    }];
    
    self.icon = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"course_leader_tag"]];
    [self.contentView addSubview:self.icon];
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.nameLb);
        make.left.equalTo(self.nameLb.mas_right).offset(10);
    }];
    
    self.descLb = [[UILabel alloc]init];
    self.descLb.font = font(14);
    self.descLb.textColor = RGBA(113, 113, 113, 1);
    self.descLb.numberOfLines = 0;
    [self.contentView addSubview:self.descLb];

    [self.descLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLb.mas_bottom).offset(16);
        make.right.equalTo(self.contentView).offset(-16);
        make.left.equalTo(self.contentView).offset(16);
        make.bottom.equalTo(self.contentView).offset(-24);
    }];
}

+(instancetype)cellWithTableView:(UITableView *)tableView{
    NSString *ID = @"LessonLeaderCell";
    LessonLeaderCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[LessonLeaderCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (void)setModel:(LessonLeaderModel *)model{
    _model = model;
    self.nameLb.text = model.userName;
    self.descLb.text = model.intro;
    [self.headerImgView sd_setImageWithURL:[NSURL URLWithString:model.photo] placeholderImage:[UIImage imageNamed:@"course_placeImg_tag"]];
    
}

@end
